{smcl}
{com}{sf}{ul off}{txt}{.-}
      name:  {res}<unnamed>
       {txt}log:  {res}C:\Users\myogo\Princeton Dropbox\Motohiro Yogo\Koijen Yogo - International\JPE\Replication\Code\4 Elasticity\Elasticity0_2.smcl
  {txt}log type:  {res}smcl
 {txt}opened on:  {res}31 Oct 2025, 10:21:37
{txt}
{com}. /* Define local and global variables */
> 
> do global;
{txt}
{com}. /* global.do (STATA)
>         Define global variables in "Elasticity".
>         by Ralph Koijen & Motohiro Yogo */
. 
. #delimit ;
{txt}delimiter now ;
{com}. clear all;
{res}{txt}
{com}. do "../3 Estimation/global";
{txt}
{com}. /* global.do (STATA)
>         Define global variables in "Estimation".
>         by Ralph Koijen & Motohiro Yogo */
. 
. #delimit ;
{txt}delimiter now ;
{com}. clear all;
{res}{txt}
{com}. global macro = "LgdpP LgdpPpc Gcpi vol drate";
{txt}
{com}. global bilateral = "dist";
{txt}
{com}. global dummies = "Iown I_CR I_OC Iyear_*";
{txt}
{com}. global dummiesA = "Itype_*";
{txt}
{com}. global iv = "IVexdemand";
{txt}
{com}. global ivA = "LSdelta*";
{txt}
{com}. 
{txt}end of do-file

{com}. global step = .01;
{txt}
{com}. 
{txt}end of do-file

{com}. /* Compute mean elasticity */
> 
> Elasticity 0 2;
{txt}
{com}. local Melast = r(Melast);
{txt}
{com}. /* Load data */
> 
> u "../3 Estimation/Estimation0", clear;
{txt}
{com}. /* Compute gradient of mean elasticity wrt demand coefficients */
> 
> mata: Delast_b = J(0,1,.);
{res}{txt}
{com}. foreach coef of varlist b_* {c -(};
{txt}  2{com}.         Elasticity 0 2 `coef';
{txt}  3{com}.         local Delast = r(Delast);
{txt}  4{com}.         mata: Delast_b = (Delast_b \ `Delast');
{txt}  5{com}. {c )-};
{res}{txt}
{com}. /* Load data */
> 
> u "../3 Estimation/Estimation0", clear;
{txt}
{com}. /* Compute gradient of mean elasticity wrt predictability coefficients */
> 
> mata: Delast_c = J(0,1,.);
{res}{txt}
{com}. foreach coef of varlist c_Lmb c_Lrealfx {c -(};
{txt}  2{com}.         Elasticity 0 2 `coef';
{txt}  3{com}.         local Delast = r(Delast);
{txt}  4{com}.         mata: Delast_c = (Delast_c \ `Delast');
{txt}  5{com}. {c )-};
{res}{txt}
{com}. /* Load estimated coefficients */
> 
> mata: mata matuse "../3 Estimation/Estimation0", replace;
{res}{txt}{p 0 1 2}
(loading
Var_b1[28,28],
Var_b2[28,28],
Var_b3[28,28],
b1[1,28],
b2[1,28],
b3[1,28])
{p_end}

{com}. mata: mata matuse "../3 Estimation/Prediction0";
{res}{txt}{p 0 1 2}
(loading
Var_c1,
Var_c2[2,2],
Var_c3[2,2],
c1,
c2[1,2],
c3[1,2])
{p_end}

{com}. /* Report mean elasticity */
> 
> di round(`Melast',.1);
{res}3.2
{txt}
{com}. /* Compute standard error by delta method */
> 
> mata: SEelast = sqrt(Delast_b'*Var_b2*Delast_b+Delast_c'*Var_c2*Delast_c);
{res}{txt}
{com}. mata: round(SEelast,.1);
{res}  .4
{txt}
{com}. log close;
      {txt}name:  {res}<unnamed>
       {txt}log:  {res}C:\Users\myogo\Princeton Dropbox\Motohiro Yogo\Koijen Yogo - International\JPE\Replication\Code\4 Elasticity\Elasticity0_2.smcl
  {txt}log type:  {res}smcl
 {txt}closed on:  {res}31 Oct 2025, 10:33:54
{txt}{.-}
{smcl}
{txt}{sf}{ul off}